package com.lanou3g.ptp.remind.entity;

import com.lanou3g.ptp.grade.service.GradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
public class GradeJob {

    @Autowired
    private StringRedisTemplate redisTemplate;

    @Autowired
    private GradeService gradeService;

    @Value("REMIND-GRADE-")
    private String REDIS_GRADEREMIND_KEY_PREFIX;

    public void gradeRemind(Long taskId){

        List<Long> teachers = gradeService.findByTaskId(taskId);

        for (Long teacher : teachers) {

            String key = REDIS_GRADEREMIND_KEY_PREFIX + taskId;

            redisTemplate.opsForValue().set(key,teacher.toString());

        }


    }
}
